<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui" template="./template.xhtml">

	<ui:define name="main">
		<h:form id="projetoForm">
			<center>
				<p:panel id="painelCadastro" header="Cadastrar Projeto"
					style="text-align:left;width:700px;">

					<h:panelGrid columns="2">
						<h:outputLabel value="#{msgs.cliente}: " />
						<h:selectOneMenu value="#{projetoBean.idCliente}">
							<f:selectItem itemLabel="Selecione" itemValue="0" />
							<f:selectItems value="#{projetoBean.listaCliente}" />
						</h:selectOneMenu>

						<h:outputLabel value="#{msgs.descricao}: " />
						<h:inputText id="descricao"
							value="#{projetoBean.projeto.descricao}" size="45" />
					</h:panelGrid>
					<br />
					<h:messages style="color:red" showDetail="false" />
					<center>
						<p:commandButton value="Gravar" action="#{projetoBean.gravar}"
							update="painelConsulta, painelCadastro" />
						<p:commandButton value="Limpar" action="#{projetoBean.limpar}"
							update="painelCadastro" />
					</center>
				</p:panel>
				<br />
				<h:messages style="color:red" showDetail="false" />
				<!-- Lista de usuarios -->
				<p:panel id="painelConsulta" header="Projetos Cadastrados"
					style="text-align:left;width:700px;">

					<p:dataTable value="#{projetoBean.listaProjetos}" id="tabela"
						emptyMessage="Nenhum registro encontrado" rowIndexVar="var"
						paginator="true" paginatorPosition="bottom"
						firstPageLinkLabel="Primeira" previousPageLinkLabel="Anterior"
						nextPageLinkLabel="Proxima" lastPageLinkLabel="ultima" rows="5"
						var="projeto" width="600">
						<p:column>
							<f:facet name="header">
								<h:outputText value="ID" />
							</f:facet>
							<h:outputText value="#{projeto.id}" styleClass="letra1" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="#{msgs.descricao}" />
							</f:facet>
							<h:outputText value="#{projeto.descricao}" styleClass="letra1" />
						</p:column>
						<p:column style="width:10px;">
							<p:commandButton image="ui-icon-pencil" title="Alterar"
								update="projetoForm">
								<f:setPropertyActionListener target="#{projetoBean.projeto}"
									value="#{projeto}" />
							</p:commandButton>
						</p:column>
						<p:column style="width:10px;">
							<p:commandButton action="#{projetoBean.excluir}"
								image="ui-icon-close" title="Excluir" update="projetoForm">
								<f:setPropertyActionListener target="#{projetoBean.projeto}"
									value="#{projeto}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</p:panel>
			</center>
		</h:form>
		<br />
	</ui:define>
</ui:composition>
